package com.platform.os.util;

import java.util.Timer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/** Initial the System Parameters.
 * @author KangJun 2007-10-6.
 */
public class ApplicationInitial extends HttpServlet {

	private static final long serialVersionUID = 1L;

	static String applactionPath = "";

    private Timer timer;

    /**
	 * Constructor of the object.
	 */
	public ApplicationInitial() {
		super();
	}

	/**
	 * Destruction of the servlet.
	 */
	public void destroy() {
		Logger.write("common", "应用关闭在" + applactionPath, this.getClass().getName());
//		timer.cancel();
		super.destroy();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		applactionPath = getServletContext().getRealPath("/");
		Logger.write("common", "应用启动在" + applactionPath , this.getClass().getName());
//		String configureFile = FileInfo.getFilePath("/WEB-INF/util.configure.xml");
//		if (!Configure.initial(configureFile)) {
//			Logger.write("common", "初始化系统参数失败！", this.getClass().getName());
//		}
//		String checkActionFile = FileInfo.getFilePath("/WEB-INF/util.checkAction.xml");
//		if (!CheckAction.initial(checkActionFile)) {
//			Logger.write("common", "初始化系统参数失败！", this.getClass().getName());
//		}
//		String schemaFile = FileInfo.getFilePath("/WEB-INF/util.schema.xml");
//		timer = new Timer();
//		if (!new CallSchema().call(timer, schemaFile)) {
//			Logger.write("common", "启动计划任务失败！", this.getClass().getName());
//		}
	}

	/** 获得应用目录.
	 * @return String
	 */
	public static String getApplactionPath() {
		return applactionPath;
	}
}
